package com.weipai.springboot.module.mapper;

import com.weipai.springboot.model.CustomerEvaluate;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface CustomerEvaluateMapper {
    int deleteByPrimaryKey(Integer evaluateId);

    int insert(CustomerEvaluate record);

    int insertSelective(CustomerEvaluate record);

    CustomerEvaluate selectByPrimaryKey(Integer evaluateId);

    int updateByPrimaryKeySelective(CustomerEvaluate record);

    int updateByPrimaryKeyWithBLOBs(CustomerEvaluate record);

    int updateByPrimaryKey(CustomerEvaluate record);

    //分页查询
    List<Map<String,Object>> selectAllByPage(@Param("start") Integer start, @Param("size") Integer size);

    //评论总数量
    Integer selectAllByPageAmount();

    //审核
    @Update("update c_customer_evaluate set is_audit=#{status} where evaluate_id=#{id}")
    int evaluateAudit(@Param("id") Integer id, @Param("status") Integer status);

    //回复评论
    @Update("update c_customer_evaluate set reply_text=#{replyText} where evaluate_id=#{id}")
    int replyEvaluate(@Param("id") Integer id, @Param("replyText") String replyText);

    //获取评论内容
    Map<String,Object> getEvaluateInfo(Integer id);

    //删除
    int batchDeleteById(String[] id);

    //查询出此货品的一条5星好评
    Map<String,Object> getOneFiveStartEvaluateBySpuNumber(String spuNumber);

    //查出此货品的5星评论总个数
    Integer getFiveStartEvaluateAmountBySpuNumber(String spuNumber);

    //查出此货品的5星评论总个数
    Integer getEvaluateAmountBySpuNumber(String spuNumber);

    //前端调用，某一货品的所有评论，分页查询
    List<Map<String,Object>> getEvaluateBySpuNumber(@Param("start") Integer start, 
                                                    @Param("size") Integer size, 
                                                    @Param("spuNumber") String spuNumber,
                                                    @Param("judgeValue") Integer judgeValue);
}